package com.cet.billingjob.service;

import com.cet.billingjob.exception.PricingException;
import org.springframework.beans.factory.annotation.Value;

import java.security.SecureRandom;
import java.util.Random;

/**
 * @author 30952
 */
public class PricingService {

    @Value("${spring.cellular.pricing.data:0.01}")
    private double dataPricing;

    @Value("${spring.cellular.pricing.call:0.5}")
    private double callPricing;

    @Value("${spring.cellular.pricing.sms:0.1}")
    private double smsPricing;

    private final Random random = new SecureRandom();

    public double getDataPricing() {
        if (random.nextInt(1000) % 117 == 0) {
            throw new PricingException("Error while retrieving data pricing");
        }

        return dataPricing;
    }

    public double getCallPricing() {
        return callPricing;
    }


    public double getSmsPricing() {
        return smsPricing;
    }

}
